<?php
namespace Rainrock\Framework\Controller;


use Rainrock\Framework\kernel\base\Base;
use Rainrock\Framework\kernel\Html\HtmlBase;
use Rainrock\Framework\kernel\Html\HtmlLabel;
use Rainrock\Framework\kernel\Html\HtmlTable;
use Rainrock\Framework\kernel\Html\HtmlInput;
use Rainrock\Framework\kernel\Html\HtmlButton;
use Rainrock\Framework\kernel\Html\HtmlImage;

/**
*	一些视图
*/
class MsgView{
	
	
	/**
	*	成功
	*/
	public static function Success($str, $gostr='', $gourl='')
	{
		return self::Show($str, 'success', $gostr, $gourl);
	}
	
	/**
	*	错误
	*/
	public static function Error($str, $gostr='', $gourl='')
	{
		return self::Show($str, 'error', $gostr, $gourl);
	}
	
	/**
	*	错误
	*/
	public static function Info($str, $gostr='', $gourl='')
	{
		return self::Show($str, 'info', $gostr, $gourl);
	}
	

	private static function Show($str, $type, $gostr='', $gourl='')
	{
		$html = HtmlBase::get();
		$html->setTitle('提示');
		
		$sdiv  = HtmlLabel::get()
			->setWidth('50px')
			->setHeight('50px')
			->addStyle('border-radius','50%')
			->addStyle('line-height','46px')
			->setFontsize(30)
			->setFontcolor('white');
		
		if($type=='success'){
			$sdiv->setBackgroundColor(APPTHEME)->addCont('✔');
		}
		
		if($type=='error'){
			$sdiv->setBackgroundColor('#D9534F')->addCont('!');
		}
		
		if($type=='info'){
			$sdiv->setBackgroundColor('#ff6600')->addCont('✔');
		}
			
		$mdivs = HtmlLabel::get()->setAlign('center')
				->addCont($sdiv)
				->addBlank(20)
				->addCont($str)
				->addCss('hui')
				->setWidth('200px')
				->addCss('border')
				->setBackgroundColor('var(--main-bgcolor)')
				->setRadius(5)
				->addStyle('margin-top','50px')
				->addStyle('padding','20px');
		
		$html->addBody($mdivs);
		
		if($gostr && $gourl){
			$html->addBody(
				HtmlLabel::get('a')
				->setDisplay('block')
				->addStyle('margin-top','20px')
				->addStyle('text-align','center')
				->setWidth('100px')
				->addCss('webbtn')
				->addCss('webbtn-default')
				->setHref($gourl)
				->addCont($gostr)
			);
		}
		
		return $html->show();
	}
}